#!/opt/python-2.5/bin/python2.5

bgcolor = "333366"
text = "EEEEEE"
font = "Arial"

import cgi, cgitb, shelve, time
cgitb.enable()
print "Content-type: text/html;charset=utf-8"
print 
print "<body bgcolor=%s text=%s>" % (bgcolor, text)
Form = cgi.FieldStorage()
if ("Comment" in Form.keys() and "Author" in Form.keys()):
	comment = Form["Comment"].value
	author = Form["Author"].value
	comm = open("tempdir/comments.all", 'a')
	curtime = time.strftime("%a, %d %b %Y at %H:%M:%S", time.gmtime())
	addend = author + " left the following feedback on " + curtime + ":\n" + comment
	comm.write(addend + "\n")
	comm.close()
	if "E-mail" in Form.keys():	
		email = Form["E-mail"].value
		emails = open("tempdir/emails.all", 'a')
		emails.write(author + " at " + email + "\n")
		emails.close()
print "<font face=%s size=4><b><center>Please leave us your feedback on the website, the Tutor, or Revelator itself:</center></b></font>" % font
print "<br/><br/>"
print "<form name=\"Comments Form\" method=post>"
print "Name:\t\t"
print "<input type=text name=\"Author\" size=30 maxlength=60 /><br/>"
print "Comments:<br/>"
print "<textarea name=\"Comment\" type=text rows=5 cols=50></textarea><br/>"
print "E-mail <i>(optional)</i>:\t\t"
print "<input type=text name=\"E-mail\" size=40 maxlength=80/><br/><br/>"
print "<button type=submit name=\"Go\">We appreciate your opinions!</button></br>"
print "</form>"
print "<hr align=center size=3 width=100% color=3399FF />"
print "<center>"
try:
	## Read previous comments.
	file = open("tempdir/comments.all", 'r')
	print "<i>Read what previous users of Revelator have said:</i><br/><br/>"
	print "<font face=Courier size=2>"
	for ac in file:
		print ac + "<br/><br/>"
	file.close()
except:
	## Write an empty shelf.
	print "<font face=Times size=5>"
	print "Be the first to express your opinion on this novel game, Revelator!"
print "</font>"
print "</center>"
print "</body>"
